package org.queryexecutor.swing.panels;

import java.awt.GridBagLayout;
import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import java.awt.Insets;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;

public class ServerPanel extends JPanel
{
	
	private static final long	serialVersionUID	= 1L;
	private JTextField txtServer;
	private JTextField txtDatabase;
	private JTextField txtUsername;
	private JPasswordField txtPassword;
		
	public JTextField getTxtServer()
	{
		return this.txtServer;
	}

	public JTextField getTxtDatabase()
	{
		return this.txtDatabase;
	}

	public JTextField getTxtUsername()
	{
		return this.txtUsername;
	}

	public JPasswordField getTxtPassword()
	{
		return this.txtPassword;
	}

	/**
	 * This is the default constructor
	 */
	public ServerPanel()
	{
		super();
		setBorder(new EmptyBorder(5, 5, 5, 5));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblServer = new JLabel("Server:");
		lblServer.setHorizontalAlignment(SwingConstants.LEFT);
		GridBagConstraints gbc_lblServer = new GridBagConstraints();
		gbc_lblServer.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblServer.insets = new Insets(0, 0, 5, 5);
		gbc_lblServer.gridx = 0;
		gbc_lblServer.gridy = 0;
		add(lblServer, gbc_lblServer);
		
		this.txtServer = new JTextField();
		this.txtServer.setColumns(10);
		GridBagConstraints gbc_txtServer = new GridBagConstraints();
		gbc_txtServer.insets = new Insets(0, 0, 5, 0);
		gbc_txtServer.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtServer.gridx = 1;
		gbc_txtServer.gridy = 0;
		add(this.txtServer, gbc_txtServer);
		
		JLabel lblDatabase = new JLabel("Database:");
		GridBagConstraints gbc_lblDatabase = new GridBagConstraints();
		gbc_lblDatabase.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblDatabase.insets = new Insets(0, 0, 5, 5);
		gbc_lblDatabase.gridx = 0;
		gbc_lblDatabase.gridy = 1;
		add(lblDatabase, gbc_lblDatabase);
		
		this.txtDatabase = new JTextField();
		this.txtDatabase.setColumns(10);
		GridBagConstraints gbc_txtDatabase = new GridBagConstraints();
		gbc_txtDatabase.insets = new Insets(0, 0, 5, 0);
		gbc_txtDatabase.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtDatabase.gridx = 1;
		gbc_txtDatabase.gridy = 1;
		add(this.txtDatabase, gbc_txtDatabase);
		
		JLabel lblUsername = new JLabel("Username:");
		GridBagConstraints gbc_lblUsername = new GridBagConstraints();
		gbc_lblUsername.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblUsername.insets = new Insets(0, 0, 5, 5);
		gbc_lblUsername.gridx = 0;
		gbc_lblUsername.gridy = 2;
		add(lblUsername, gbc_lblUsername);
		
		this.txtUsername = new JTextField();
		this.txtUsername.setColumns(10);
		GridBagConstraints gbc_txtUsername = new GridBagConstraints();
		gbc_txtUsername.insets = new Insets(0, 0, 5, 0);
		gbc_txtUsername.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtUsername.gridx = 1;
		gbc_txtUsername.gridy = 2;
		add(this.txtUsername, gbc_txtUsername);
		
		JLabel lblPassword = new JLabel("Password:");
		GridBagConstraints gbc_lblPassword = new GridBagConstraints();
		gbc_lblPassword.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblPassword.insets = new Insets(0, 0, 0, 5);
		gbc_lblPassword.gridx = 0;
		gbc_lblPassword.gridy = 3;
		add(lblPassword, gbc_lblPassword);
		
		this.txtPassword = new JPasswordField();
		GridBagConstraints gbc_txtPassword = new GridBagConstraints();
		gbc_txtPassword.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtPassword.gridx = 1;
		gbc_txtPassword.gridy = 3;
		add(this.txtPassword, gbc_txtPassword);
		initialize();
	}
	
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize()
	{
		this.setSize(300, 103);
	}
	
}
